package com.example.demo.utils;

import lombok.SneakyThrows;
import org.springframework.core.convert.converter.Converter;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName DateConverter
 * @Author bsy
 * @Description TODO
 * @Date 2022/8/24 22:30
 * @Version 1.0
 */
public class DateConverter implements Converter<String, Date> {

    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @SneakyThrows
    @Override
    public Date convert(String source) {
        if (source != null && !"".equals(source)) {
            simpleDateFormat.parse(source);
        }
        return null;
    }
}
